package com.googlecode.imanager.jasper.util;

import com.googlecode.imanager.jasper.print.RChild;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class RVerticalPrintComparator extends RPrintComparator {

    public static final RVerticalPrintComparator INSTANCE = new RVerticalPrintComparator();
    
    protected RVerticalPrintComparator() {
    }
    
    @Override
    public int getLength(RChild a) {
        return a.getHeight() + ((RChild)a).getRInsets().getVertical();
    }

    @Override
    public int getStartPos(RChild a) {
        return a.getY() - ((RChild)a).getRInsets().getTop();
    }

    @Override
    public void setLength(RChild a, int value) {
        a.setHeight(value - ((RChild)a).getRInsets().getVertical());
    }

    @Override
    public void setStartPos(RChild a, int value) {
        a.setY(value + ((RChild)a).getRInsets().getTop());
    }
    
    @Override
    public RPrintComparator getOpposition() {
        return RHorizontalPrintComparator.INSTANCE;
    }

}